dnl # M4 code to translate the m4-schema into SQL statements that
dnl # update the metadata database with the schema for this relation
dnl #
dnl m4 stuff to allow the injection of code
include(FileLoaderFunctions.m4)
m4_include(FileLoaderDefs.m4)
dnl #
/* Deleting old content (if it exists) */
DELETE FROM CatalogAttributes WHERE relID=(SELECT relID FROM CatalogRelations WHERE relation='RELATION_NAME');
DELETE FROM CatalogRelations WHERE relation='RELATION_NAME';

/* Adding the new relation in Catalog*/
INSERT INTO CatalogRelations(relation) VALUES ( 'RELATION_NAME' );
m4_foreach(</_C_/>, </COLUMN_TYPES/>, </dnl
INSERT INTO CatalogAttributes(attribute, type, relID)
VALUES ( 'M4_COL_NAME(_C_)' , 'M4_COL_TYPE(_C_)', (SELECT relID FROM CatalogRelations WHERE relation='RELATION_NAME'));
/>)

m4_ifndef(</DISK_ARRAY/>, m4_define(</DISK_ARRAY/>, </Default/>)) dnl #
dnl #
dnl # /* Adding the new relation in the DiskArray */
dnl # INSERT INTO Relations(arrayID, relName, numColumns, freeChunkId)
dnl # VALUES ( (SELECT arrayID from DiskArrays WHERE name='DISK_ARRAY'),
dnl # 'RELATION_NAME', (SELECT COUNT(*) FROM CatalogAttributes A, CatalogRelations R WHERE R.relation='RELATION_NAME' and A.relID=R.relID) ,
dnl # 0);
